package modularity.passiveDrift;

import java.util.ArrayList;

public class ModularGenome extends ArrayList<BasicGenome> implements Genome<ConnectionGene> {

	private static final long serialVersionUID = 1L;

	private String name;
	
	public ModularGenome(BasicGenome[] initialModules){
		super(initialModules.length);
		for(int i = 0; i < initialModules.length; i++){
			super.add(initialModules[i]);
		}
	}

	public int getNumberOfModules(){
		return super.size();
	}

	@Override
	public ArrayList<ConnectionGene> getGenomicComponents() {
		ArrayList<ConnectionGene> genomicComponents = new ArrayList<ConnectionGene>();
		for(BasicGenome subGenome : this){
			genomicComponents.addAll(subGenome.getGenomicComponents());
		}
		return genomicComponents;
	}

	@Override
	public int getNumberOfConnections() {
		int connections = 0;
		for(BasicGenome g : this)
			connections += g.getNumberOfConnections();
		
		return connections;
	}

	@Override
	public int getNumberOfNodes() {
		int nodes = 0;
		for(BasicGenome g : this)
			nodes += g.getNumberOfNodes();
		
		return nodes;
	}

	@Override
	public String getName() {
		return name;
	}
	
	public void setName(String name){
		this.name = name;
	}

}
